package cn.myjerry.decorator;

/**
 * 抽象构建
 * @author Jerry
 *
 */
public interface ICar {
	void move();
}
// 真实对象
class Car implements ICar {
	@Override
	public void move() {
		System.out.println("地上跑。。。");
	}
}
// 装饰角色
class SuperCar implements ICar {
	protected ICar car;
	
	public SuperCar(ICar car) {
		super();
		this.car = car;
	}

	@Override
	public void move() {
		car.move();
	}
}
// 具体装饰对象
class FlyCar extends SuperCar {
	public FlyCar(ICar car) {
		super(car);
	}
	public void fly() {
		System.out.println("天上飞。。。");
	}
	@Override
	public void move() {
		super.move();
		fly();
	}
}

class WaterCar extends SuperCar {
	public WaterCar(ICar car) {
		super(car);
	}
	public void water() {
		System.out.println("水上游。。。");
	}
	@Override
	public void move() {
		super.move();
		water();
	}
}

class AiCar extends SuperCar {
	public AiCar(ICar car) {
		super(car);
	}
	public void ai() {
		System.out.println("自动跑。。。");
	}
	@Override
	public void move() {
		super.move();
		ai();
	}
}
